<?php
/*  
  Copyright (c) 2010-02 SongCMS 
  SongCMS All Rights Reserved. 
  Support:www.SongCMS.com
  QQ:544255858   19951025
  Author:Song  Version:3.17
  Date:2010-08-12 09:28:32
*/

include_once('Admin.php');
!is_numeric($_GET['page']) ? $page = 1 : $page = (int)($_GET['page']);
$PageCount = $PageManagePage; //每页要显示的数量
$ColumnType = 0; //栏目类型:0栏目内容分类,1新闻分类,2产品分类

if($_GET['Action'] == 'Del'){
	if(!is_numeric(($_GET['ID']))) MsgBox (1,'您提交的参数有误！','-1');
	if(in_array($_GET['ID'],$NotDelPage)){AdminLog(3,$Lang,'尝试删除受保护的文章内容(ID:' . $_GET['ID'] . ')，结果：操作被拒绝！'); MsgBox (1,'非法操作，该内容为系统默认内容，必须保留，您可以修改该内容！','-1');}
	$pics = new pics();
	$pics->remove_upload_files($_GET['ID'],0);		
	if($db->ExecuteSQL("DELETE FROM `" . $dbprefix . "Article` WHERE `ID` = '" . $_GET['ID'] . "' LIMIT 1")){
		$admin -> delcomment(0,$_GET['ID']);
		AdminLog(3,$Lang,'删除文章内容(ID:' . $_GET['ID'] . ')，结果：操作成功！'); 
		MsgBox (0,'','PageManage.php?Lang=' . $Lang . '&page=' . $page);
	} else {
		AdminLog(3,$Lang,'删除文章内容(ID:' . $_GET['ID'] . ')，结果：操作失败！'); 
		MsgBox (1,'操作失败！','-1');
	}
}
if($_POST['Action'] == 'AllDel'){
	$AllDel = $_POST['AllDel'];
	$AllDel != '' ? $AllDel = array_merge(array_diff($AllDel,$NotDelPage)) : MsgBox (1,'操作失败，请选择要删除的文章内容！','-1'); //从选择的文章ID中移去配置文件中禁止删除的文章内容ID
	$AllDel = implode(',',$AllDel); //Array转成字串
	$pics = new pics();
	$pics->remove_upload_files($AllDel,0);		
	if($db->ExecuteSQL("DELETE FROM `" . $dbprefix . "article` WHERE `ID` IN (" . $AllDel . ")")){
		$admin -> delcomment(0,$AllDel);
		AdminLog(3,$Lang,'批量删除文章内容(ID:' . $AllDel . ')，结果：操作成功！'); 
		unset($AllDel);
		MsgBox (1,'操作成功！','PageManage.php?Lang=' . $Lang . '&page=' . $page);		
	} else {
		AdminLog(3,$Lang,'批量删除文章内容，结果：操作失败！'); 
		unset($AllDel);
		MsgBox (1,'操作失败！','-1');		
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="./images/adminstyle.css" rel="stylesheet" type="text/css" />
<link rel="Shortcut Icon" href="../favicon.ico">
<link rel="Bookmark" href="../favicon.ico">
<script type="text/javascript"> 
function CheckAll(form) { 
	for (var i=0;i<form.elements.length;i++) { 
		var e = form.elements[i]; 
		if (e.Name != "chkAll"&&e.disabled!=true) 
		e.checked = form.chkAll.checked; 
	} 
} 
</script>
<script src="../js/csshovernotie6.js" type="text/javascript"></script>
</head>
<body>
<br />
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr class="Notodd">
	<td><?php TopLang();?></td>
	<td align="right">
	<select onchange="window.open(this.options[this.selectedIndex].value,'_self')">
	<option value="PageManage.php?Lang=<?php echo $Lang;?>">==显示所有栏目内容==</option>
<?php
$Rs = $db->SelectSQL("SELECT `ID`,`ColumnRela`,`ColumnName`,`ColumnLevel`,`ColumnTime`,`ColumnSort` FROM `" . $dbprefix . "column` WHERE ColumnType = $ColumnType && ColumnLang = $Lang;",2);
@$Rs = sdb::column_sort($Rs);
for ($i=0;$i<count($Rs);$i++ ) {
	Html($Rs[$i]);
	for ($x=1;$x<$Rs[$i][3];$x++){$Spaces .= '├┈┈';} //加与栏目级数相同的空格
	$Rs[$i][3] > 1 ? $Spaces = $Spaces . $Rs[$i][2] : $Spaces = $Rs[$i][2]; //一级栏目前不加空格符
	if ($_GET['ArticleRela'] != $Rs[$i][1]){
		echo '<option value="PageManage.php?Lang=' . $Lang . '&ArticleRela=' . $Rs[$i][1] . '">' . $Spaces . '</option>' . "\n";
	}else{
		echo '<option selected="selected" value="PageManage.php?Lang=' . $Lang . '&ArticleRela=' . $Rs[$i][1] . '">' . $Spaces . '</option>' . "\n";
	}
	unset($Spaces);
}
unset($Rs,$i,$x);
?> 
</select>
		<input type="button" value="发布内容" onClick="javascript:location.href='PageAdd.php?Lang=<?php echo $Lang?>'">
		<input type="button" value="栏目管理" onClick="javascript:location.href='PageColumnManage.php?Lang=<?php echo $Lang?>'">
	</td>
	</tr>
</table>
<table width="98%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#CCCCCC">
  <form id="form1" name="form1" method="post" action="PageManage.php?Lang=<?php echo $Lang?>&page=<?php echo $page?>">
  <tr class="odd">
    <td colspan="6" align="center" class="Main_Title">内容管理<?php echo $OnWebLangName?></td>
  </tr>
  <tr class="odd">
    <td width="50" align="center"><input name="chkAll" type="checkbox" id="chkAll" onclick="CheckAll(this.form)" value="checkbox"></td>
    <td align="center"><strong>ID</strong></td>
    <td align="center"><strong>所属栏目</strong></td>
    <td align="center"><strong>内容标题<? if($ConfigArticleClick==1){echo'(点击数)';}?></strong></td>
    <td align="center"><strong>添加日期</strong></td>
    <td align="center"><strong>管理选项</strong></td>
  </tr>
<?php
$SQL = "SELECT `ID`,`ArticleRela`,`ArticleTitle`,`ArticleImg`,`ArticleClick`,`ArticleTime` FROM `" . $dbprefix . "article` "; 
$SQL .= "WHERE `ArticleLang` = '" . $Lang . "' ";
if($_GET['ArticleRela'] != '') {$SQL .= "&& `ArticleRela` LIKE '%" . $_GET['ArticleRela'] . "%' ";}
$RsCount = count($db->SelectSQL($SQL)); //总记录数
$SQL .= "ORDER BY `ArticleSort` DESC,`ID` DESC "; 
$SQL .= "LIMIT " . ($page-1)*$PageCount . " , " . $PageCount . " ";
$Rs = $db->SelectSQL($SQL);
if (count($Rs)==0){echo '<tr class="odd"><td height="50" colspan="6" align="center" style="font-size:15px; color:#333333;">没有相关数据！<a href="PageAdd.php?Lang=' . $Lang . '">添加内容</a></td></tr>';}
for ($i=0;$i<count($Rs);$i++){
	$ConfigArticleClick==1 ? $Click = '(<font color="#FF0000">' . $Rs[$i][4] . '</font>)' : $Click = '';
	if (!in_array($Rs[$i][0],$NotDelPage)){echo '<tr class="odd">';} else {echo '<tr class="odd" id="ippv">';}
	echo '<td align="center"><input name="AllDel[]" type="checkbox" id="AllDel[]" value="' . $Rs[$i][0] . '" /></td>
	<td align="center">' . $Rs[$i][0] . '</td>
	<td align="left">' . htmlspecialchars(ArticleName($Rs[$i][1])) . '</td>
	<td align="left">' . Html($Rs[$i][2]) . $Click . '</td>
	<td align="center">' . $Rs[$i][5] . '</td>
	<td align="center"><a href="PagePreview.php?ID=' . $Rs[$i][0] . '">预览</a>&nbsp;|&nbsp;
	<a href="PageUpDate.php?Lang=' . $Lang . '&ID=' . $Rs[$i][0] . '">修改</a>&nbsp;|&nbsp;
	<a onClick="return confirm(\'确定删除该内容吗？\');" href="?Lang=' . $Lang . '&page=' . $page . '&Action=Del&ID=' . $Rs[$i][0] . '">删除</a></td>
	</tr>';
}
unset($Rs)
?>  
<tr class="odd">
    <td align="center"><input onClick="return confirm('确定要删除所有选定的内容吗？');"  type="submit" name="button" id="button" value="删除" />
      <input name="Action" type="hidden" id="Action" value="AllDel" /></td>
    <td colspan="6" align="center" height="30"><?php echo pages('Lang=' . $Lang . '&ArticleRela=' . $_GET['ArticleRela'])?></td>
    </tr>
  </form>
</table>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="6">
	<tr class="Notodd">
		<td style="color:#333333; line-height:20px;">
注：1、灰色(标题名称颜色)内容为系统保护的文章内容，防止前台默认数据被误删，可能有部分内容做了防删处理；<br />
　　2、受保护的内容无法删除，您可以对其进行修改、更新、改名、移动等操作；<br />
　　3、您还可以在系统高级参数设定中取消/添加受保护的内容；
</td>
	</tr>
</table>
</body>
</html>